package yhao.demo.service.erp.workflow.apilist.model.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import yhao.demo.service.erp.workflow.apilist.enums.task.RuleItemType;
import yhao.infra.common.model.Entity;

public class TaskNodeItemModel extends Entity<String> {
    /************ 事项配置常量值 **********/
    public final static String ITEM_RESULT = "result";

    @ApiModelProperty("当前任务ID")
    private String taskId;
    @ApiModelProperty("当前节点ID")
    private String taskNodeId;
    @ApiModelProperty("事项名称")
    private String itemName;
    @ApiModelProperty("事项条目设置，json格式，包含数组内容，数组内元素至少含有{\"result\"}结果项")
    private String itemConfig;
    @ApiModelProperty("事项结果")
    private String itemResult;
    @ApiModelProperty("期望结果")
    private String itemExcept;
    @ApiModelProperty("期望类型")
    private RuleItemType itemExceptType;
    @ApiModelProperty("是否必要条件")
    private boolean necessary;

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getTaskNodeId() {
        return taskNodeId;
    }

    public void setTaskNodeId(String taskNodeId) {
        this.taskNodeId = taskNodeId;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getItemConfig() {
        return itemConfig;
    }

    public void setItemConfig(String itemConfig) {
        this.itemConfig = itemConfig;
    }

    public String getItemResult() {
        return itemResult;
    }

    public JSONArray getItemConfigJson() {
        if(StringUtils.isEmpty(itemConfig)){
            return null;
        }else{
            return JSONObject.parseArray(itemConfig);
        }
    }

    public void setItemResult(String itemResult) {
        this.itemResult = itemResult;
    }

    public String getItemExcept() {
        return itemExcept;
    }

    public void setItemExcept(String itemExcept) {
        this.itemExcept = itemExcept;
    }

    public RuleItemType getItemExceptType() {
        return itemExceptType;
    }

    public void setItemExceptType(RuleItemType itemExceptType) {
        this.itemExceptType = itemExceptType;
    }

    public boolean isNecessary() {
        return necessary;
    }

    public void setNecessary(boolean necessary) {
        this.necessary = necessary;
    }
}
